-
Notifications
You must be signed in to change notification settings - Fork 0
feature: add transaction forwarding #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes introduce a transaction forwarding configuration and implementation for submitting raw Ethereum transactions to an external sequencer via JSON-RPC. This includes new command-line arguments, a forwarding configuration struct, a concurrency- and rate-limited HTTP forwarder with authentication support, and associated metrics and error handling. The workspace and crate manifests are reorganized and updated with new dependencies. Unit tests are added for both the forwarder and network builder logic. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Node
participant TxForwarder
participant Sequencer
User->>Node: Submit raw transaction
Node->>TxForwarder: forward_raw(raw_tx)
TxForwarder->>Sequencer: POST eth_sendRawTransaction (with auth, rate/queue limits)
Sequencer-->>TxForwarder: JSON-RPC response (tx hash or error)
TxForwarder-->>Node: Result (tx hash or ForwardError)
Node-->>User: Acknowledge submission (or error)
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @tac0turtle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a significant new feature to the Lumen node: the ability to forward Ethereum transactions to an external sequencer. This functionality allows the node to integrate with external sequencing services, providing a flexible alternative to traditional local transaction pool processing and network gossip. The changes involve adding new configuration options, implementing a dedicated forwarding service, and integrating this service into the existing RPC API layer.
Highlights
- Transaction Forwarding Capability: Implemented a mechanism to forward raw RLP-encoded Ethereum transactions directly to an external sequencer via HTTP, enabling the node to act as a transaction relayer.
- Configurable Sequencer Endpoint: Added new command-line arguments (
--sequencer-http
,--sequencer-auth
,--disable-tx-pool-gossip
) to thelumen
binary, allowing users to specify the sequencer's HTTP endpoint, authentication credentials, and an option to disable local transaction pool gossip when forwarding is active. - RPC API Integration: Introduced
EthApiForwarder
, a wrapper around the existingEthApiServer
implementation. This forwarder interceptseth_sendRawTransaction
andeth_sendRawTransactionSync
calls, redirecting them to the configured sequencer, while all other RPC methods continue to be handled by the local node. - Robust Transaction Submission: Developed
TxForwarder
with built-in features for rate-limiting, concurrency control, and metrics collection, ensuring reliable and observable transaction submission to the sequencer. - Dependency Updates: Updated
Cargo.lock
andCargo.toml
to include new crates such asgovernor
(for rate-limiting),jsonrpsee
(for RPC client functionality),reqwest
(for HTTP requests),metrics
andprometheus
(for observability), andwiremock
(for testing), along with variousreth
andalloy
component updates.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR introduces transaction forwarding, enabling nodes to send transactions to a remote sequencer. I've identified potential panic issues in TxForwarder
and suggested improvements for error propagation in EthApiForwarder
. Overall, this is a valuable addition.
crates/node/src/eth_api_forwarder.rs
Outdated
.map_err(|e| { | ||
jsonrpsee::types::error::ErrorObject::owned( | ||
jsonrpsee::types::error::INTERNAL_ERROR_CODE, | ||
format!("Failed to forward transaction: {e}"), | ||
None::<String>, | ||
) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling masks the original error from the remote RPC endpoint. Forward the original JSON-RPC error object when available to provide more context.
.map_err(|e| match e {
jsonrpsee::core::Error::Call(err) => err,
other => jsonrpsee::types::error::ErrorObject::owned(
jsonrpsee::types::error::INTERNAL_ERROR_CODE,
format!("Failed to forward transaction: {}", other),
None::<String>,
),
})
pub sequencer_http: Option<String>, | ||
/// Optional Basic-Auth header | ||
pub sequencer_auth: Option<String>, | ||
/// Disable transaction pool gossip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR introduces transaction forwarding to a sequencer, with a new TxForwarder
and an EthApiForwarder
to wrap the existing Eth RPC API. The review focuses on improving error handling in the RPC wrapper and reducing boilerplate code for better maintainability.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
marking this as r4r but we should test before merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
crates/node/src/lib.rs (1)
33-34
: Add documentation fordisable_tx_pool_gossip
field.This field lacks documentation explaining its purpose and impact on transaction handling.
/// Optional Basic-Auth header pub sequencer_auth: Option<String>, - /// Disable transaction pool gossip + /// Disable transaction pool gossip when forwarding to sequencer. + /// When enabled, prevents local mempool from gossiping forwarded transactions to peers. pub disable_tx_pool_gossip: bool,
🧹 Nitpick comments (3)
crates/node/src/forwarder.rs (3)
46-50
: Document the non-zero requirement forrate_limit_per_sec
.The constructor will panic if
rate_limit_per_sec
is 0. Consider adding this requirement to the documentation./// * `endpoint` – The sequencer endpoint (e.g. <http://localhost:8547>). /// * `queue_size` – Maximum number of in-flight requests (mapped onto a semaphore). - /// * `rate_limit_per_sec` – Maximum POST requests per second sent to the sequencer. + /// * `rate_limit_per_sec` – Maximum POST requests per second sent to the sequencer (must be > 0).
101-108
: Consider adding a timeout for HTTP requests.Network requests to the sequencer could hang indefinitely. Consider adding a timeout to prevent resource exhaustion.
- let mut req = self.client.post(self.endpoint.clone()).json(&payload); + let mut req = self.client + .post(self.endpoint.clone()) + .timeout(std::time::Duration::from_secs(30)) + .json(&payload);
150-151
: Remove or utilize the unusedRateLimited
error variant.The
RateLimited
error variant is defined but never used in the code. Either remove it or consider returning it when the rate limiter blocks requests.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
📒 Files selected for processing (6)
Cargo.toml
(2 hunks)bin/lumen/src/main.rs
(2 hunks)crates/node/Cargo.toml
(1 hunks)crates/node/src/eth_api_forwarder.rs
(1 hunks)crates/node/src/forwarder.rs
(1 hunks)crates/node/src/lib.rs
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`crates/**/src/**/*.rs`: Unit tests should be written for individual components.
crates/**/src/**/*.rs
: Unit tests should be written for individual components.
📄 Source: CodeRabbit Inference Engine (CLAUDE.md)
List of files the instruction was applied to:
crates/node/src/lib.rs
crates/node/src/eth_api_forwarder.rs
crates/node/src/forwarder.rs
`bin/lumen/src/main.rs`: The `RollkitEngineTypes` in `bin/lumen/src/main.rs` sho...
bin/lumen/src/main.rs
: TheRollkitEngineTypes
inbin/lumen/src/main.rs
should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
TheRollkitEngineValidator
inbin/lumen/src/main.rs
should bypass certain checks for Rollkit compatibility while maintaining security and allowing flexible block production.
📄 Source: CodeRabbit Inference Engine (CLAUDE.md)
List of files the instruction was applied to:
bin/lumen/src/main.rs
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/node/src/builder.rs : The `RollkitPayloadBuilder` in `crates/node/src/builder.rs` should accept transactions from Engine API payload attributes, execute transactions, build blocks, and manage state transitions.
crates/node/src/lib.rs (4)
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/node/src/builder.rs : The `RollkitPayloadBuilder` in `crates/node/src/builder.rs` should accept transactions from Engine API payload attributes, execute transactions, build blocks, and manage state transitions.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineValidator` in `bin/lumen/src/main.rs` should bypass certain checks for Rollkit compatibility while maintaining security and allowing flexible block production.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/tests/**/*.rs : Integration tests should be placed in `crates/tests/` and cover Engine API interactions, payload building with transactions, state execution validation, and Rollkit-specific scenarios.
bin/lumen/src/main.rs (5)
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineValidator` in `bin/lumen/src/main.rs` should bypass certain checks for Rollkit compatibility while maintaining security and allowing flexible block production.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/node/src/builder.rs : The `RollkitPayloadBuilder` in `crates/node/src/builder.rs` should accept transactions from Engine API payload attributes, execute transactions, build blocks, and manage state transitions.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Run the node with defaults using `make run`, with debug logs using `make run-dev`, or directly via `./target/release/lumen node ...`.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/tests/**/*.rs : Integration tests should be placed in `crates/tests/` and cover Engine API interactions, payload building with transactions, state execution validation, and Rollkit-specific scenarios.
Cargo.toml (5)
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineValidator` in `bin/lumen/src/main.rs` should bypass certain checks for Rollkit compatibility while maintaining security and allowing flexible block production.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/tests/**/*.rs : Integration tests should be placed in `crates/tests/` and cover Engine API interactions, payload building with transactions, state execution validation, and Rollkit-specific scenarios.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/**/src/**/*.rs : Unit tests should be written for individual components.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Test specific crates using `make test-node`, `make test-rollkit`, or `make test-common`.
crates/node/src/eth_api_forwarder.rs (3)
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/node/src/builder.rs : The `RollkitPayloadBuilder` in `crates/node/src/builder.rs` should accept transactions from Engine API payload attributes, execute transactions, build blocks, and manage state transitions.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/tests/**/*.rs : Integration tests should be placed in `crates/tests/` and cover Engine API interactions, payload building with transactions, state execution validation, and Rollkit-specific scenarios.
crates/node/Cargo.toml (7)
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Run the node with defaults using `make run`, with debug logs using `make run-dev`, or directly via `./target/release/lumen node ...`.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineValidator` in `bin/lumen/src/main.rs` should bypass certain checks for Rollkit compatibility while maintaining security and allowing flexible block production.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Maintain a modular workspace structure to separate concerns between general node logic and Rollkit-specific features.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/node/src/builder.rs : The `RollkitPayloadBuilder` in `crates/node/src/builder.rs` should accept transactions from Engine API payload attributes, execute transactions, build blocks, and manage state transitions.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Test specific crates using `make test-node`, `make test-rollkit`, or `make test-common`.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/tests/**/*.rs : Integration tests should be placed in `crates/tests/` and cover Engine API interactions, payload building with transactions, state execution validation, and Rollkit-specific scenarios.
crates/node/src/forwarder.rs (4)
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/node/src/builder.rs : The `RollkitPayloadBuilder` in `crates/node/src/builder.rs` should accept transactions from Engine API payload attributes, execute transactions, build blocks, and manage state transitions.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineValidator` in `bin/lumen/src/main.rs` should bypass certain checks for Rollkit compatibility while maintaining security and allowing flexible block production.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/tests/**/*.rs : Integration tests should be placed in `crates/tests/` and cover Engine API interactions, payload building with transactions, state execution validation, and Rollkit-specific scenarios.
🔇 Additional comments (6)
crates/node/Cargo.toml (1)
77-86
: LGTM! Dependencies align with forwarding feature requirements.The added dependencies appropriately support the transaction forwarding implementation:
reqwest
for HTTP client functionalitygovernor
for rate limitingreth-metrics
for instrumentationwiremock
for testing the forwarding logicbin/lumen/src/main.rs (1)
74-99
: Well-structured CLI arguments for transaction forwarding.The new arguments properly support the forwarding feature with:
- Clear help text and value names
- Environment variable support for sensitive auth data
- Appropriate default values
Cargo.toml (1)
1-128
: Clean workspace manifest reorganization.The alphabetization and consistent formatting improve maintainability. The new dependencies appropriately support the transaction forwarding features.
crates/node/src/eth_api_forwarder.rs (3)
130-135
: Verify intended behavior forsend_transaction
.The
send_transaction
method delegates to the inner implementation rather than forwarding to the remote sequencer. This allows local signing before the transaction is forwarded as a raw transaction. Please confirm this is the intended flow for transaction submission.
137-165
: Error handling properly preserves remote errors.The implementation correctly addresses past review feedback by preserving the original error objects from the remote sequencer, providing better error context to clients.
151-165
: Verifyeth_sendRawTransactionSync
implementation in remote endpoint
The method simply forwards to"eth_sendRawTransactionSync"
and assumes the remote node will return the receipt typeR
. Since this is a custom (non-standard) RPC provided by reth-rpc-api v1.5.x + Alloy 0.7, please confirm:
- That
eth_sendRawTransactionSync
is actually defined in your RPC trait (e.g., in reth-rpc-api)- That the target node you’re forwarding to supports this endpoint and returns the expected receipt structure
R
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use tokio; | ||
use wiremock::{ | ||
matchers::{method, path}, | ||
Mock, MockServer, ResponseTemplate, | ||
}; | ||
|
||
#[tokio::test] | ||
async fn happy_path() { | ||
// Spin up a mock sequencer. | ||
let server = MockServer::start().await; | ||
|
||
// Mock 200 OK with a zero tx-hash. | ||
let body = serde_json::json!({ | ||
"jsonrpc": "2.0", | ||
"id": 1, | ||
"result": format!("0x{}", "00".repeat(32)) | ||
}); | ||
Mock::given(method("POST")) | ||
.and(path("/")) | ||
.respond_with(ResponseTemplate::new(200).set_body_json(body)) | ||
.mount(&server) | ||
.await; | ||
|
||
let forwarder = TxForwarder::new( | ||
server.uri().parse().unwrap(), | ||
/*queue_size*/ 10, | ||
/*rate_limit*/ 1_000, | ||
/*auth*/ None, | ||
None, | ||
); | ||
|
||
let hash = forwarder | ||
.forward_raw(Bytes::from_static(b"\x01\x02")) | ||
.await | ||
.expect("forwarding should succeed"); | ||
|
||
assert_eq!(hash, B256::ZERO); | ||
} | ||
|
||
#[tokio::test] | ||
async fn http_error() { | ||
let server = MockServer::start().await; | ||
|
||
// Mock 500 Internal Server Error. | ||
Mock::given(method("POST")) | ||
.and(path("/")) | ||
.respond_with(ResponseTemplate::new(500)) | ||
.mount(&server) | ||
.await; | ||
|
||
let forwarder = TxForwarder::new(server.uri().parse().unwrap(), 10, 1_000, None, None); | ||
|
||
let err = forwarder | ||
.forward_raw(Bytes::from_static(b"\x03\x04")) | ||
.await | ||
.expect_err("should return error"); | ||
|
||
matches!(err, ForwardError::HttpStatus(status) if status == reqwest::StatusCode::INTERNAL_SERVER_ERROR); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Expand test coverage for comprehensive testing.
Per the coding guidelines, unit tests should be written for individual components. Consider adding tests for:
- Authentication header handling
- Invalid JSON responses
- Invalid transaction hash responses
- Upstream JSON-RPC errors
- Concurrent request handling (queue behavior)
Would you like me to generate additional test cases to improve coverage?
🤖 Prompt for AI Agents
In crates/node/src/forwarder.rs between lines 172 and 234, the existing tests
cover basic success and HTTP error scenarios but lack coverage for
authentication headers, invalid JSON responses, invalid transaction hash
responses, upstream JSON-RPC errors, and concurrent request handling. To fix
this, add new unit tests that specifically verify the correct inclusion and
handling of authentication headers, simulate and assert behavior on invalid JSON
and transaction hash responses, test how upstream JSON-RPC errors are handled,
and create tests that send multiple concurrent requests to validate queue
behavior and rate limiting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/node/src/eth_api_forwarder.rs (1)
1-6
: Consider addressing clippy warnings instead of suppressing them.Suppressing warnings can hide code quality issues. Consider:
- Using lifetime elision where possible
- Breaking down complex types into type aliases
- Refactoring functions with many arguments into builder patterns or structs
- Using
if let
for single-arm matches
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
crates/node/src/eth_api_forwarder.rs
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`crates/**/src/**/*.rs`: Unit tests should be written for individual components.
crates/**/src/**/*.rs
: Unit tests should be written for individual components.
📄 Source: CodeRabbit Inference Engine (CLAUDE.md)
List of files the instruction was applied to:
crates/node/src/eth_api_forwarder.rs
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/node/src/builder.rs : The `RollkitPayloadBuilder` in `crates/node/src/builder.rs` should accept transactions from Engine API payload attributes, execute transactions, build blocks, and manage state transitions.
crates/node/src/eth_api_forwarder.rs (2)
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/node/src/builder.rs : The `RollkitPayloadBuilder` in `crates/node/src/builder.rs` should accept transactions from Engine API payload attributes, execute transactions, build blocks, and manage state transitions.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: test
- GitHub Check: test
- GitHub Check: e2e
- GitHub Check: MSRV
🔇 Additional comments (3)
crates/node/src/eth_api_forwarder.rs (3)
30-48
: LGTM!Clean struct design with appropriate use of
Arc
for thread-safe access to the remote client.
50-106
: LGTM!Standard delegation pattern correctly implemented for all required traits.
122-127
: LGTM!Correct delegation pattern for transaction signing before forwarding.
crates/node/src/eth_api_forwarder.rs
Outdated
.await | ||
} | ||
async fn call_many( | ||
&self, | ||
bundles: Vec<Bundle>, | ||
state_context: Option<StateContext>, | ||
state_override: Option<StateOverride>, | ||
) -> RpcResult<Vec<Vec<EthCallResponse>>> { | ||
self.inner | ||
.call_many(bundles, state_context, state_override) | ||
.await | ||
} | ||
async fn create_access_list( | ||
&self, | ||
request: TransactionRequest, | ||
block_number: Option<BlockId>, | ||
state_override: Option<StateOverride>, | ||
) -> RpcResult<AccessListResult> { | ||
self.inner | ||
.create_access_list(request, block_number, state_override) | ||
.await | ||
} | ||
async fn estimate_gas( | ||
&self, | ||
request: TransactionRequest, | ||
block_number: Option<BlockId>, | ||
state_override: Option<StateOverride>, | ||
) -> RpcResult<U256> { | ||
self.inner | ||
.estimate_gas(request, block_number, state_override) | ||
.await | ||
} | ||
async fn gas_price(&self) -> RpcResult<U256> { | ||
self.inner.gas_price().await | ||
} | ||
async fn get_account(&self, addr: Address, block: BlockId) -> RpcResult<Option<Account>> { | ||
self.inner.get_account(addr, block).await | ||
} | ||
async fn max_priority_fee_per_gas(&self) -> RpcResult<U256> { | ||
self.inner.max_priority_fee_per_gas().await | ||
} | ||
async fn blob_base_fee(&self) -> RpcResult<U256> { | ||
self.inner.blob_base_fee().await | ||
} | ||
async fn fee_history( | ||
&self, | ||
block_count: U64, | ||
newest: BlockNumberOrTag, | ||
reward_percentiles: Option<Vec<f64>>, | ||
) -> RpcResult<FeeHistory> { | ||
self.inner | ||
.fee_history(block_count, newest, reward_percentiles) | ||
.await | ||
} | ||
|
||
// ---------- mining / hashrate -------------------------------------------- | ||
async fn is_mining(&self) -> RpcResult<bool> { | ||
self.inner.is_mining().await | ||
} | ||
async fn hashrate(&self) -> RpcResult<U256> { | ||
self.inner.hashrate().await | ||
} | ||
async fn get_work(&self) -> RpcResult<Work> { | ||
self.inner.get_work().await | ||
} | ||
async fn submit_hashrate(&self, hashrate: U256, id: B256) -> RpcResult<bool> { | ||
self.inner.submit_hashrate(hashrate, id).await | ||
} | ||
async fn submit_work(&self, nonce: B64, pow_hash: B256, mix_digest: B256) -> RpcResult<bool> { | ||
self.inner.submit_work(nonce, pow_hash, mix_digest).await | ||
} | ||
|
||
// ---------- signing ------------------------------------------------------- | ||
async fn sign(&self, addr: Address, data: Bytes) -> RpcResult<Bytes> { | ||
self.inner.sign(addr, data).await | ||
} | ||
async fn sign_transaction(&self, transaction: TransactionRequest) -> RpcResult<Bytes> { | ||
self.inner.sign_transaction(transaction).await | ||
} | ||
async fn sign_typed_data( | ||
&self, | ||
addr: Address, | ||
data: alloy_dyn_abi::TypedData, | ||
) -> RpcResult<Bytes> { | ||
self.inner.sign_typed_data(addr, data).await | ||
} | ||
|
||
// ---------- proofs -------------------------------------------------------- | ||
async fn get_proof( | ||
&self, | ||
addr: Address, | ||
keys: Vec<JsonStorageKey>, | ||
at: Option<BlockId>, | ||
) -> RpcResult<EIP1186AccountProofResponse> { | ||
self.inner.get_proof(addr, keys, at).await | ||
} | ||
async fn get_account_info(&self, addr: Address, at: BlockId) -> RpcResult<AccountInfo> { | ||
self.inner.get_account_info(addr, at).await | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add unit tests for the EthApiForwarder.
According to the coding guidelines, unit tests should be written for components in crates/**/src/**/*.rs
. The forwarder's transaction forwarding logic and error handling would benefit from test coverage.
Consider testing:
- Error handling when remote client returns different error types
- Correct delegation of methods to inner vs remote
- Concurrent access to the shared HttpClient
Would you like me to generate unit tests for the EthApiForwarder?
🤖 Prompt for AI Agents
In crates/node/src/eth_api_forwarder.rs covering the entire EthApiForwarder
implementation, add unit tests to verify the transaction forwarding logic and
error handling. Write tests that simulate the remote HttpClient returning
various error types to ensure proper error mapping. Also, test that methods
correctly delegate to either the inner implementation or the remote client as
intended. Include concurrency tests to validate safe shared access to the
Arc-wrapped HttpClient. Use mocking for the inner EthApiServer and HttpClient to
isolate and verify behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
bin/lumen/src/network_test.rs (1)
29-38
: Expand test coverage for argument parsing scenarios.The test only covers the
--disable-tx-pool-gossip
flag but doesn't test theenable_rollkit
behavior mentioned in the comment above. Consider adding tests for:
- Different combinations of flags
- The
enable_rollkit
flag behavior- Invalid argument scenarios
#[test] fn test_rollkit_args_parsing() { // Test parsing with gossip disabled let args = RollkitArgs::parse_from(["lumen", "--disable-tx-pool-gossip"]); assert!(args.disable_tx_pool_gossip); // Test parsing without the flag (default) let args = RollkitArgs::parse_from(["lumen"]); assert!(!args.disable_tx_pool_gossip); + + // Test enable_rollkit behavior if it exists + // Add tests for different flag combinations + // Add tests for invalid scenarios }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
bin/lumen/src/main.rs
(8 hunks)bin/lumen/src/network_test.rs
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- bin/lumen/src/main.rs
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/node/src/builder.rs : The `RollkitPayloadBuilder` in `crates/node/src/builder.rs` should accept transactions from Engine API payload attributes, execute transactions, build blocks, and manage state transitions.
bin/lumen/src/network_test.rs (6)
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineValidator` in `bin/lumen/src/main.rs` should bypass certain checks for Rollkit compatibility while maintaining security and allowing flexible block production.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/tests/**/*.rs : Integration tests should be placed in `crates/tests/` and cover Engine API interactions, payload building with transactions, state execution validation, and Rollkit-specific scenarios.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to bin/lumen/src/main.rs : The `RollkitEngineTypes` in `bin/lumen/src/main.rs` should provide custom Engine API types supporting transaction submission and handle payload attribute validation and processing.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Test specific crates using `make test-node`, `make test-rollkit`, or `make test-common`.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/**/src/**/*.rs : Unit tests should be written for individual components.
Learnt from: CR
PR: rollkit/lumen#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T15:38:11.650Z
Learning: Applies to crates/node/src/builder.rs : The `RollkitPayloadBuilder` in `crates/node/src/builder.rs` should accept transactions from Engine API payload attributes, execute transactions, build blocks, and manage state transitions.
🧬 Code Graph Analysis (1)
bin/lumen/src/network_test.rs (1)
bin/lumen/src/main.rs (5)
new
(255-259)new
(390-392)new
(415-419)new
(505-512)default
(516-518)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: doc tests
- GitHub Check: test
- GitHub Check: test
- GitHub Check: MSRV
🔇 Additional comments (3)
bin/lumen/src/network_test.rs (3)
1-4
: LGTM: Clean test module setup.The imports are appropriate and the test module is properly configured.
6-11
: LGTM: Test correctly verifies gossip disabled behavior.The test properly validates that creating a
RollkitNetworkBuilder
withtrue
sets thedisable_tx_pool_gossip
flag correctly.
13-18
: LGTM: Test correctly verifies gossip enabled behavior.The test properly validates that creating a
RollkitNetworkBuilder
withfalse
leaves thedisable_tx_pool_gossip
flag as false.
// Note: enable_rollkit defaults to false with #[derive(Default)] | ||
// but is set to true when parsed from CLI | ||
assert!(!args.enable_rollkit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify the inconsistent default behavior for enable_rollkit
.
The comment suggests that enable_rollkit
defaults to false
with #[derive(Default)]
but is set to true
when parsed from CLI. This inconsistency could be confusing and should be verified.
🏁 Script executed:
#!/bin/bash
# Description: Search for enable_rollkit field definition and CLI parsing logic
# Expected: Find the field definition and understand why CLI parsing differs from Default
# Search for enable_rollkit field definition
echo "=== Searching for enable_rollkit field definition ==="
ast-grep --pattern $'struct $_ {
$$$
enable_rollkit: $_,
$$$
}'
# Search for CLI parsing logic that might set enable_rollkit to true
echo "=== Searching for CLI parsing logic ==="
rg -A 10 -B 5 "enable_rollkit.*true"
# Search for clap annotations on enable_rollkit
echo "=== Searching for clap annotations ==="
rg -A 5 -B 5 "#\[.*enable_rollkit"
Length of output: 439
🏁 Script executed:
#!/bin/bash
# Deep search for all references to enable_rollkit across the repository
rg -n "enable_rollkit"
Length of output: 256
Update network_test.rs comment to accurately describe enable_rollkit default
The enable_rollkit
flag remains false
by default—both via #[derive(Default)]
and when parsed from the CLI—and only becomes true
if --enable-rollkit
is passed.
• bin/lumen/src/network_test.rs: lines 24–26
Suggested diff:
- // Note: enable_rollkit defaults to false with #[derive(Default)]
- // but is set to true when parsed from CLI
+ // Note: enable_rollkit defaults to false both by Default and when parsed from the CLI
+ // and can be enabled by passing the --enable-rollkit flag
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// Note: enable_rollkit defaults to false with #[derive(Default)] | |
// but is set to true when parsed from CLI | |
assert!(!args.enable_rollkit); | |
// Note: enable_rollkit defaults to false both by Default and when parsed from the CLI | |
// and can be enabled by passing the --enable-rollkit flag | |
assert!(!args.enable_rollkit); |
🤖 Prompt for AI Agents
In bin/lumen/src/network_test.rs around lines 24 to 26, update the comment to
correctly state that the enable_rollkit flag defaults to false both with
#[derive(Default)] and when parsed from the CLI, and only becomes true if the
--enable-rollkit option is passed. Replace the existing comment with this
accurate description to avoid confusion.
this will be integrated into native reth and we will update to that version |
Description
This Pr allows nodes to forward txs to the sequencer if set.
ref rollkit/rollkit#2390
Type of Change
Related Issues
Fixes #(issue)
Checklist
Testing
Additional Notes
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores